package com.billjc.activity.service;

import java.util.Map;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.billjc.activity.prop.EcsParams;
import com.google.common.collect.Maps;

import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class EcsProcessServiceImpl implements ProcessService {
	@Autowired
	private RuntimeService runtimeService;
	@Autowired
	private EcsParams ecsParams;

	@Override
	public String invoker(String requestParams) {
		log.info("执行ecs流程获取到的参数： {}",requestParams);
		// 启动实例时设置流程全局参数
		Map<String, Object> vars = Maps.newHashMap();
		vars.put("ecsInfo", requestParams);
		// 启动ecs流程实例
		ProcessInstance instance = runtimeService.startProcessInstanceByKey(ecsParams.getProcessName(), vars);
		return instance.getId();

	}
}
